package com.dlc.shop.distribution.api.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dlc.shop.common.response.ServerResponseEntity;
import com.dlc.shop.common.util.PageParam;
import com.dlc.shop.distribution.common.dto.DistributionMsgDto;
import com.dlc.shop.distribution.common.model.DistributionMsg;
import com.dlc.shop.distribution.common.service.DistributionMsgService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yami
 */
@RestController
@RequestMapping("/p/distribution/msg")
@Tag(name = "分销公告接口")
@AllArgsConstructor
public class DistributionMsgController {

    private final DistributionMsgService distributionMsgService;

    @GetMapping("/info")
    @Operation(summary = "获取公告详情" , description = "根据公告id获取")
    @Parameter(name = "msgId", description = "公告id" , required = true)
    public ServerResponseEntity<DistributionMsgDto> info(Long msgId){
        return ServerResponseEntity.success(distributionMsgService.getDistributionMsgDtoByMsgId(msgId));
    }

    @GetMapping("/page")
    @Operation(summary = "公告列表")
    @Parameters({
            @Parameter(name = "isTop", description = "是否置顶" )
    })
    public ServerResponseEntity<IPage<DistributionMsgDto>> page(PageParam<DistributionMsg> page,
                                                          @RequestParam(value = "isTop", required = false) Integer isTop) {
        return ServerResponseEntity.success(distributionMsgService.getDistributionMsgDtoShopId(page,isTop));
    }
}
